package gof.com.yew.memento;

//源发器类
public class Originator {
	private String name ;
	
	//构造器
	public Originator() {}
	
	//保存快照
	public Memento saveState() {
		return new Memento(this.name);
	}
	
	//恢复快照
	public void revertState(Memento men) {
		this.name = men.getName();
		if(this.name == null || "".equals(name)) {
			name = "已还原";
		}
	}
	
	//撤销快照
	public void revokeState(Memento men) {
		this.name = men.getName();
		if(this.name == null || "".equals(name)) {
			name = "已还原";
		}
	}

	public String getName() {

		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Originator [name=" + name + "]";
	}

}
